package leetcode;

import util.LinkList;
import util.ListNode;

/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2487.java
 * @Author : WangRuoyu
 * @Date 2023/2/24 9:47
 */
public class Q2487 {
    static ListNode find(ListNode head) {
        if (head.next == null) return head;
        head.next = find(head.next);
        if (head.val < head.next.val) return head.next;
        return head;
    }

    public ListNode removeNodes(ListNode head) {
        return find(head);
    }

    public static void main(String[] args) {
        Q2487 sl = new Q2487();
        ListNode head = LinkList.createList(new int[]{5, 2, 13, 3, 8});
        ListNode p = sl.removeNodes(head);
        LinkList.printList(p);
    }
}